package Navigator.Systemer;

import Navigator.student.StudentDao;
import Navigator.student.StudentEnity;
import Worker.WorkerDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "updateStudentServlet")
public class updateStudentServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        StudentDao studentDao=new StudentDao();
        String studentNo=request.getParameter("studentNo");
        String studentName=request.getParameter("studentName");
        String sex=request.getParameter("sex");
        String className=request.getParameter("className");
        String collage=request.getParameter("collage");
        String studentPas=request.getParameter("studentPas");
        int row=studentDao.updateStudent(studentNo,studentName,sex,className,collage,studentPas);
        if(row>0){
            response.sendRedirect("/SystemerNav/StudentMangement.jsp?studentNo="+studentNo);
        }else {
            response.getWriter().println("修改出错,请后退重试");
        }
    }
}
